#include "stdafx.h"
#include "CodeSafeProto.h"
#include "SessionEventHandler.h"


void DecodeID_MESSAGE1_RPT(const void * buf, int nSize, CSessionEventHandler * pProc)
{
    PKG_MESSAGE1_RPT pkg;
    if (!pkg.ParseFromArray(buf, nSize))
        return;
    if (pProc){
        pProc->message1_proc(&pkg);
    }
}

CCodeSafeProto::CCodeSafeProto()
{
    GOOGLE_PROTOBUF_VERIFY_VERSION;
    memset(m_DecodeFuncArray, 0, sizeof(m_DecodeFuncArray));
    Init();
}

CCodeSafeProto::~CCodeSafeProto()
{
    google::protobuf::ShutdownProtobufLibrary();
}

bool CCodeSafeProto::Init()
{
    m_DecodeFuncArray[ID_MESSAGE1_RPT] = &DecodeID_MESSAGE1_RPT;
    return true;
}

void CCodeSafeProto::Decode(int nMsgID, const void * buf, int nSize, CSessionEventHandler * pProc)
{
    if(nMsgID > CodeSafeProtoMaxMessageID || m_DecodeFuncArray[nMsgID] == NULL){
        return;
    }
    m_DecodeFuncArray[nMsgID](buf, nSize, pProc);
}

